<template>
    <el-dialog v-if="dialogVisible" :close-on-click-modal='false' v-loading="loading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)" title="批量修改基础信息" top="8vh" :visible.sync="dialogVisible" @close="resetForm()" width="800px">
        <div class="free_box flexbox">
            <div class="free_left flex">
                <div class="free_title">已选需求</div>
                <div class="dam_list">
                    <div class="dam_item" v-for="item in hasSelect" :key="item.id">
                        <div class="dam_name"><span class="color_01">{{item.brand_name}}</span> - {{item.product_name}}</div>
                        <div class="dam_text flexbox flexcenter">需求ID：{{item.id}} <span class="dam_line"></span> 当前核心创意人：{{item.centre_name}}</div>
                    </div>
                </div>
            </div>
            <div class="free_right flex">
                <div class="free_title">基础信息</div>
                <div class="dam_form">
                    <svg class="dam_icon" width="57" height="67" viewBox="0 0 57 67" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path d="M49 48V8.00004C49 5.79089 47.433 4.00004 45.5 4.00004L10.5 4C8.567 4 6.99999 5.79087 7 8.00001L7.00007 48C7.00007 50.2092 8.56707 52 10.5001 52H45.5C47.433 52 49 50.2092 49 48Z" fill="#4475FF" stroke="#4475FF" stroke-width="4" stroke-linejoin="round" />
                        <path d="M27.9994 14.7373L25.2486 20.3194L19 21.2202L23.5265 25.6196L22.4444 31.7373L27.9994 28.7933L33.5555 31.7373L32.4814 25.6196L37 21.2202L30.7861 20.3194L27.9994 14.7373Z" fill="white" stroke="white" stroke-width="4.66667" stroke-linejoin="round" />
                        <path opacity="0.6" d="M21.3682 41.7373H34.6313" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" />
                        <g opacity="0.45" filter="url(#filter0_f_8352_99405)">
                            <path d="M45.8112 49H11.1888C9.97995 49 9 49.31 9 49.6923V57.3077C9 57.69 9.97995 58 11.1888 58H45.8112C47.0201 58 48 57.69 48 57.3077V49.6923C48 49.31 47.0201 49 45.8112 49Z" fill="#4475FF" />
                        </g>
                        <defs>
                            <filter id="filter0_f_8352_99405" x="0" y="40" width="57" height="27" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
                                <feFlood flood-opacity="0" result="BackgroundImageFix" />
                                <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
                                <feGaussianBlur stdDeviation="4.5" result="effect1_foregroundBlur_8352_99405" />
                            </filter>
                        </defs>
                    </svg>
                    <div class="dam_title">批量修改基础信息</div>
                    <div class="dam_tips">修改的信息将应用到所选需求上</div>
                    <el-form class="dam_edit" label-position="top" label-width="auto" :hide-required-asterisk='true' :model="queryInfo" :rules="eidtRules" ref="editForm">
                        <el-form-item label="核心创意人" prop="centre_uid">
                            <el-select v-model="queryInfo.centre_uid" filterable placeholder="请选择核心创意人" style="width:100%">
                                <el-option label="无需修改" :value="0"></el-option>
                                <el-option :label="item.nickname" :value="item.id" v-for="item in centreList" :key="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="剪辑" prop="editor_uid">
                            <el-select v-model="queryInfo.editor_uid" filterable placeholder="请选择剪辑" style="width:100%">
                                <el-option label="无需修改" :value="0"></el-option>
                                <el-option :label="item.nickname" :value="item.id" v-for="item in hzClipList" :key="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="截止日期" prop="closing_date">
                            <el-select v-model="queryInfo.closing_date" filterable placeholder="请选择截止日期" style="width:100%">
                                <el-option label="无需修改" :value="0"></el-option>
                                <el-option :label="item.nickname" :value="item.id" v-for="item in dataList" :key="item.id"></el-option>
                                <!-- <el-option label="周一" :value="1"></el-option>
                                <el-option label="周二" :value="2"></el-option>
                                <el-option label="周三" :value="3"></el-option>
                                <el-option label="周四" :value="4"></el-option>
                                <el-option label="周五" :value="5"></el-option>
                                <el-option label="周六" :value="6"></el-option>
                                <el-option label="周日" :value="7"></el-option> -->
                            </el-select>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="resetForm('editForm')" class="el-button-width">取 消</el-button>
            <el-button size="small" type="primary" @click="submitForm('editForm')" :disabled="disabled" :loading="disabled" class="el-button-width">确 认</el-button>
        </span>
    </el-dialog>
</template>

<script>
export default {
    props:["dataList"],
    name: "",
    data() {
        return {
            loading: false,
            disabled: false,
            dialogVisible: false,
            centreList: [], //核心创意人
            hzClipList: [], //剪辑
            hasSelect: [],
            queryInfo: {
                centre_uid: 0,
                editor_uid: 0,
                closing_date: 0,
                id: [],
            },
            eidtRules: {
                centre_uid: [
                    {
                        required: true,
                        message: "请选择核心创意人",
                        trigger: "blur",
                    },
                ],
                editor_uid: [
                    {
                        required: true,
                        message: "请选择剪辑",
                        trigger: "blur",
                    },
                ],
                closing_date: [
                    {
                        required: true,
                        message: "请选择截止日期",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
    created() {},
    beforeDestroy() {},
    methods: {
        // 获取核心创意人列表
        async getCentreList() {
            const { data: res } = await this.$http.post(
                "adminapi/company/szCentreList"
            );
            if (res.code !== 200) {
                this.$message.error(res.msg);
                return;
            } else {
                this.centreList = res.data;
            }
        },

        // 获取剪辑
        async getClipList() {
            const { data: res } = await this.$http.post(
                "adminapi/company/szClipperList"
            );
            if (res.code !== 200) {
                this.$message.error(res.msg);
                return;
            } else {
                this.hzClipList = res.data;
            }
        },

        // 提交添加
        submitForm(formName) {
            this.$refs[formName].validate(async (valid) => {
                if (valid) {
                    this.disabled = true;
                    this.queryInfo.id = this.hasSelect.map((item) => {
                        return item.id;
                    });
                    const { data: res } = await this.$http.post(
                        "/adminapi/demandsz/videoCentreBatch",
                        this.queryInfo
                    );
                    if (res.code !== 200) {
                        this.disabled = false;
                        this.$message.error(res.msg);
                        return;
                    } else {
                        this.disabled = false;
                        this.$message({
                            message: "修改成功",
                            type: "success",
                        });
                        this.$parent.getDataList(this.$parent.queryInfo.page);
                        this.$parent.closeCheck();
                        this.resetForm('editForm');
                    }
                } else {
                    this.disabled = false;
                    return false;
                }
            });
        },

        resetForm(formName) {
            this.hasSelect = [];
            this.$refs[formName].resetFields();
            this.queryInfo.id = [];
            this.dialogVisible = false;
        },
    },
    components: {},
};
</script>


<style scoped>
.free_box {
    margin: -20px -20px -10px -20px;
    position: relative;
    border-bottom: 1px solid #ebebeb;
    overflow: hidden;
}
.free_box::after {
    content: "";
    position: absolute;
    height: 100%;
    border-left: 1px solid #ebebeb;
    left: 50%;
    top: 0;
}
.free_title {
    height: 61px;
    line-height: 61px;
    padding: 0 20px;
    font-size: 16px;
    color: #17233d;
    border-bottom: 1px solid #ebebeb;
}
.dam_list {
    height: 475px;
    margin: 8px 0px;
    padding: 0 20px;
    overflow-y: auto;
}
.dam_item {
    padding: 12px 20px;
    border: 1px solid #ebebeb;
    border-radius: 6px;
    margin: 12px 0;
}
.dam_name {
    font-size: 14px;
    color: #616c85;
}
.dam_text {
    font-size: 12px;
    color: #b4b7bd;
    margin-top: 8px;
    line-height: 17px;
}
.dam_line {
    border-left: 1px solid #ebebeb;
    margin: 0 16px;
    height: 8px;
}
.dam_form {
    padding: 25px 20px 0;
}
.dam_icon {
    display: block;
    margin: 0 auto;
}
.dam_title {
    font-size: 16px;
    color: #17233d;
    text-align: center;
}
.dam_tips {
    font-size: 14px;
    color: #b4b7bd;
    margin-top: 8px;
    text-align: center;
    margin-bottom: 25px;
}
.dam_center {
    width: 360px;
    margin-top: 24px;
}
.dam_edit .el-form-item {
    margin-bottom: 16px;
}
</style>
